package jay.home.bet.web.struts;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import jay.home.bet.domain.Order;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.DynaActionForm;

public class KillOrderAction extends BaseAction
{
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception
	{
		DynaActionForm df = (DynaActionForm) form;
		String orderid = df.getString("orderid");
		
		Order order = getOrderService().getOrder(orderid);
		String oid = order.getId();
		Double oamount = order.getAmount();
		String ouser = order.getUsername();
		getOrderService().deleteOrder(order);
		request.setAttribute("orderid", oid);
		request.setAttribute("amount", oamount);
		request.setAttribute("username", ouser);
		return mapping.findForward("SUCCESS");
	}
}
